function getProducts(iMode)
{


if(!crmForm.IsValid())
{
return;
}



var aoItems = crmForm.all.opportunityid.DataValue;
var sOppID="", sOppName="";
if(aoItems != null)
{
sOppID = aoItems[0].id;
sOppName = aoItems[0].name;
}
var oResult = openStdDlg(prependOrgName("/sfa/quotes/dlg_products.aspx?opportunityid=") + CrmEncodeDecode.CrmUrlEncode(sOppID) + "&name=" + CrmEncodeDecode.CrmUrlEncode(sOppName), null, 400, 200);

if(oResult)
{
var oOpportunityId = createHiddenInput("gpOpportunityId", oResult.opportunityId);

if (!crmForm.SubmitCrmForm(iMode, true, true, false))
{


deleteInput(oOpportunityId);
}
}
}


function CheckIsProductOverridden()
{
var s = crmFormSubmit.crmFormSubmitXml.value;

if (crmForm.all.isproductoverridden.DataValue)
{
s = s.replace(/<productid.*productid>/, "");
s = s.replace(/<uomid.*uomid>/, "");
}
else
{
s = s.replace(/<productdescription.*productdescription>/, "");
}

crmFormSubmit.crmFormSubmitXml.value = s;
}


function GetQuantityDecimal(objectTypeCode, objectId, productId, uomId)
{
var oXmlDoc	= CreateXmlDocument(false);
var oXmlHTTP = CreateXmlHttp();

oXmlHTTP.open("POST", prependOrgName("/sfa/quotes/cmd_getquantitydecimal.aspx?objectTypeCode=") + CrmEncodeDecode.CrmUrlEncode(objectTypeCode) + "&objectId=" + CrmEncodeDecode.CrmUrlEncode(objectId) + "&productId=" + CrmEncodeDecode.CrmUrlEncode(productId) + "&uomId=" + CrmEncodeDecode.CrmUrlEncode(uomId), false);
oXmlHTTP.send(oXmlDoc);

return parseInt(oXmlHTTP.responseXML.selectSingleNode("quantitydecimal").text, 10);
}

function locCustomAddRelatedToNonForm(iTypeToAdd, createFromType, createFromId, additionalAttributes)
{
if (crmForm.pricelevelid.DataValue == null)
{
alert(LOCID_PRICE_LIST_NOT_SELECTED);
}
else if (crmForm.pricelevelid.IsDirty)
{
alert(LOCID_PRICE_LIST_NOT_SAVED);
}
else
{
var sUrl = "?_CreateFromType=" + CrmEncodeDecode.CrmUrlEncode(createFromType) + "&_CreateFromId=" + CrmEncodeDecode.CrmUrlEncode(createFromId) + additionalAttributes;
openFrmObj( sUrl, buildWinName(), iTypeToAdd );
}
}